#!/bin/bash
#

function check_oim-server() {
    netstat -tunlp | grep java | grep 12020 | awk '{print $NF}' | awk -F '/' '{print $1}' &> /dev/null
    REVTAL=$?
    
    if [ $REVTAL -eq 0 ]; then 
        oim_pid=`netstat -tunlp | grep java | grep 12020 | awk '{print $NF}' | awk -F '/' '{print $1}'`
        echo "$(date +%Y-%m-%d" "%H:%M:%S) - - oim-server service is running: ${oim_pid}."
    else
        bash /chat_new/oim-server-run-single-boot/oim_control.sh start
    fi
}


while true; do
    check_oim-server
    sleep 60s
done